Skip to content

dofs: Add bounded filesystem primitives - #79

Merged
aron-cf merged 16 commits into
mainfrom
stack/improve-tools-01-dofs-primitives
Aug 11, 2026
Merged

dofs: Add bounded filesystem primitives#79
aron-cf merged 16 commits into
mainfrom
stack/improve-tools-01-dofs-primitives

Conversation

@aron-cf

@aron-cf aron-cf commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Stack 1 of 7. Base: main. Head: stack/improve-tools-01-dofs-primitives.

The storage filesystem could not page directories after merging pending writes, expose bounded byte reads through its main facade, match single-character globs, or bound search results. Tool callers therefore had to transfer too much data or implement behavior outside the authoritative storage layer.

This change adds stable name-ordered directory pages with size and modification time, including entries held in write buffers. It exposes byte-range reads on WorkspaceFilesystem, adds ? glob matching, and extends grep with fixed-string and regular-expression modes, explicit case handling, context lines, limits, and offsets. Existing grep callers retain literal, case-sensitive defaults.

Verification

npm test --workspace @cloudflare/dofs
npm run typecheck --workspace @cloudflare/dofs
npm run build --workspace @cloudflare/dofs

The next stack part carries these bounded primitives through the Computer facade and AI tool adapters.

@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: 3da7bfa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/dofs Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for your interest in Cloudflare Computer.

This repository does not accept unsolicited pull requests. Please use one of the accepted contribution paths instead:

If a maintainer asked you to open this pull request, they can add the allow-pr label and reopen it.

@github-actions github-actions Bot closed this Aug 7, 2026
@aron-cf aron-cf added the allow-pr Allow a PR to remain open. label Aug 7, 2026
@aron-cf aron-cf reopened this Aug 7, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@79

commit: 3da7bfa

@aron-cf
aron-cf marked this pull request as ready for review August 7, 2026 15:20
@aron-cf
aron-cf force-pushed the stack/improve-tools-01-dofs-primitives branch from b85296c to 80d82a8 Compare August 7, 2026 15:29
devin-ai-integration[bot]

This comment was marked as resolved.

aron-cf added 10 commits August 10, 2026 12:35
Return file size and modification time from readdir, and apply limit and
offset after pending write buffers are merged into stable name order.
Add readRange to WorkspaceFilesystem so callers can read a byte window
without materializing or transferring the whole file.
Teach find that a question mark matches one non-separator character so
its glob surface covers the pattern documented by the AI find tool.
Keep literal, case-sensitive defaults while adding regular expressions,
explicit case handling, numbered context, and limit and offset controls
for tool callers.
Keep the new pagination tests compliant with the repository-wide Biome
import ordering check.
Record the directory, range-read, glob, and grep additions with the
storage package that introduces them.
@aron-cf
aron-cf force-pushed the stack/improve-tools-01-dofs-primitives branch from 9a8959c to 73e565c Compare August 10, 2026 13:22
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +121 to +130
function compileMatcher(pattern: string, options: { regex: boolean; ignoreCase: boolean }): RegExp {
const source = options.regex ? pattern : pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
try {
return new RegExp(source, options.ignoreCase ? "i" : "");
} catch (error) {
throw new TypeError(
`Invalid regular expression: ${error instanceof Error ? error.message : String(error)}`,
);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煥 User-supplied regular expressions can be compiled and run against file contents (ReDoS)

The new regex: true grep mode compiles the caller-supplied pattern verbatim into a RegExp (compileMatcher at packages/dofs/src/fs/grep.ts:121-130) and evaluates it per line over every file under the search root (packages/dofs/src/fs/grep.ts:145-146). A catastrophically backtracking pattern (e.g. (a+)+$) applied to long lines can block the isolate/event loop for an unbounded time, since there is no execution budget, line-length cap, or pattern complexity check. Prior behaviour was fixed-string search only, so this expands the attack surface when the pattern originates from an untrusted tool caller.

Open in Devin Review

Was this helpful? React with 馃憤 or 馃憥 to provide feedback.

@aron-cf
aron-cf merged commit ae708d7 into main Aug 11, 2026
18 checks passed
@aron-cf
aron-cf deleted the stack/improve-tools-01-dofs-primitives branch August 11, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-pr Allow a PR to remain open.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant